﻿<%@ page contentType="text/html; charset=utf-8" import="com.util.Component"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>交卡厂制卡登记</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8" />
<script src="${pageContext.request.contextPath }/scripts/boot.js" type="text/javascript"></script>
<style type="text/css">
<!--
#Layer1 {
	position:absolute;
	left:20%;
	top:94px;
	width:628px;
	height:325px;
	z-index:1;
}
-->
</style>
</head>

<body>

<div id="Layer1">
<form id="form"  method="post">
<div style="width:100%;" align="center">
  <div class="mini-toolbar" style="border-bottom:0;padding:0px;">
    <table style="width:100%;">
      <tr>
        <td style="width:100%;text-align:center;"><font face="宋体"><strong>交卡厂制卡登记</strong></font></td>
      </tr>
    </table>
  </div>
</div>
<div >
<table  style="width:100%;border:solid 1px #aaa;width:100%;">
<tr>
<td width="20%" height="49" style="white-space:nowrap;text-align:right">制作卡厂</td>
<td colspan="3" ><input name="azf030" class="mini-combobox" style="width:100%" textField="azf031" valueField="azf030" required="true"  emptytext="请选择..." 
url="${pageContext.request.contextPath }/kid.do?method=getzkks" onvaluechanged="getzkkslxr"/></td>
<td width="5%" style="white-space:nowrap;text-align:right">制卡批次</td>
<td width="28%"><input name="aaz001" class="mini-textbox" maxlength="12" required="true" emptyText="请输入制卡批次" /></td>
</tr>
<tr>
<td height="40" width="15%" style="white-space:nowrap;text-align:right">银行</td>
<td width="15%"><input name="aae008" class="mini-combobox" textField="aaa103" valueField="aaa102" required="true"  emptyText="请输入..." 
url="${pageContext.request.contextPath }/kid.do?method=getyinhang&sj=bank" onvaluechanged="getdcnumber"/></td>
<td width="15%" style="white-space:nowrap;text-align:right">卡厂联系人</td>
<td width="15%"><input name="azf032" class="mini-textbox" maxlength="16" required="true" emptyText="请输入卡厂联系人" /></td>
<td width="15%" style="white-space:nowrap;text-align:right">送交日期</td>
<td width="15%"><input name="aaz717" class="mini-datepicker" required="true" value="<%=Component.systime()%>"  emptyText="请输入送交日期"  /></td>
</tr>
<tr>
<td height="45" style="white-space:nowrap;text-align:right">导出数据量</td>
<td><input name="aaz400" class="mini-textbox" required="true" maxlength="6" emptyText="请获取导出数据量" allowInput="false"/></td>
<td style="white-space:nowrap;text-align:right">送交数量</td>
<td><input name="aaz704" class="mini-textbox" vtype="int" required="true" maxlength="6" emptyText="请输入送交数量" onvaluechanged="checksjsl"/></td>
<td style="white-space:nowrap;text-align:right">送交前不制卡数量</td>
<td><input name="aaz743" class="mini-textbox" required="true" readOnly="true" maxlength="6" emptyText="请输入送交前不制卡数量" allowInput="false"/></td>
</tr>
<tr>
<td height="40" colspan="6" style="width:100%;text-align:center;">
          <a class="mini-button" iconCls="icon-ok" id="ok" onclick="onOk">确认</a>
          <a class="mini-button" iconCls="icon-print" onclick="ExportExcel()" >打印</a>
          <a class="mini-button" iconCls="icon-remove"  onclick="onReset" >重置</a></td>
</tr>
</table>
</div>
</form>
</div>
<script type="text/javascript">
mini.parse();
var form = new mini.Form("form");
 function onOk(e) {
        
           SaveData();
        }
        
        function SaveData() {             
			var o = form.getData();				
			form.validate();
			var aaz704=mini.getbyName("aaz704").getValue();
			var json = mini.encode([o]);
			if (form.isValid() == false){
			return;		
			} else if(aaz704==0){
			   mini.alert("请输入正确的送交数量！");
			   return;
			} else {
			$.ajax({
				url : "/sbk/kid.do?method=jkczkdj",
				type : 'post',
				data : {
					data : json
				},
				cache : false,
				success : function(text) {	
				     if("0"== text)
				    {
				     mini.alert("登记成功");
				     mini.get("ok").setEnabled(false);
				    }
				    else
				    {
				      mini.alert("登记失败");
				    }
				    labelModel();					   						   										
				},
				error : function(jqXHR, textStatus, errorThrown) {
					mini.alert(jqXHR.responseText);					
				}
			});
			}
		}	
		function getzkkslxr(e){
		    $.ajax({
				url : "/sbk/kid.do?method=getkslxr",
				type : 'post',
				data : {
					ksid:e.value
				},
				cache : false,
				success : function(text) {	
				  mini.getbyName("azf032").setValue(text);
				    						
				},
				error : function(jqXHR, textStatus, errorThrown) {
					mini.alert(jqXHR.responseText);					
				}
			});
		}
		function onReset(e) {
			form.clear();
			inputModel();
			mini.getbyName("aaz717").setValue('<%=Component.systime()%>');
			mini.get("ok").setEnabled(true);
		}	
		function getdcnumber(e){
		var aaz001=mini.getbyName("aaz001").getValue();
		if(aaz001==""||aaz001==null){
		mini.alert("请输入制卡批次！");
		return;
		}
		$.ajax({
				url : "/sbk/kid.do?method=getdcnumber",
				type : 'post',
				data : {
					aae008:e.value,aaz001:aaz001
				},
				cache : false,
				success : function(text) {
				var o = mini.decode(text);
				if (o.error != ""&& o.error !=null) {
				mini.alert(o.error);	
				mini.getbyName("aae008").setValue("");
				mini.getbyName("aaz400").setValue("");
				} else {
				mini.getbyName("aaz400").setValue(o.aaz400);
				}    						
				},
				error : function(jqXHR, textStatus, errorThrown) {
					mini.alert(jqXHR.responseText);					
				}
			});
		}	
		function checksjsl(e){
		var aaz400=mini.getbyName("aaz400").getValue();
		if(aaz400==""||aaz400==null){
		mini.alert("请先获取导出数据量！");
		mini.getbyName("aaz704").setValue("");
		return;
		}
		if(Number(e.value)>Number(aaz400)||Number(e.value)<0){
		mini.alert("请输入正确的送交数量！");
		mini.getbyName("aaz704").setValue("");
		return;
		}
		mini.getbyName("aaz743").setValue(Number(aaz400)-Number(e.value));
		}
		 function labelModel() {
            var fields = form.getFields();                
            for (var i = 0, l = fields.length; i < l; i++) {
                var c = fields[i];
                if (c.setReadOnly) c.setReadOnly(true);     //只读
                if (c.setIsValid) c.setIsValid(true);      //去除错误提示
                if (c.addCls) c.addCls("asLabel");          //增加asLabel外观
            }
        }
        function inputModel() {
            var fields = form.getFields();
            for (var i = 0, l = fields.length; i < l; i++) {
                var c = fields[i];
                if (c.setReadOnly) c.setReadOnly(false);
                if (c.removeCls) c.removeCls("asLabel");
            }
            mini.repaint(document.body);
        }
</script>
</body>
</html>
